<!-- 使用 type="home" 属性设置首页 -->
<route lang="json">
{
  "style": { "navigationBarTitleText": "数字分身" },
  "name": "aiAgent"
}
</route>
<template>
  <view class="container" :class="{ 'theme-dark': theme === 'dark', 'theme-light': theme === 'light' }">
    <!-- Profile Header -->
    <view class="profile-header">
      <view class="avatar-container">
        <view class="avatar">
          <text class="avatar-text">AI</text>
        </view>
        <view class="status-dot"></view>
      </view>
      <text class="profile-name">DeepSeek智能助手</text>
      <text class="profile-did">DID: did:web3:0x2a6f...7c23</text>

      <view class="chat-container">
        <view class="chat-header">
          <view class="header-content">
            <view class="ai-avatar">
              <text class="ai-icon">🤖</text>
            </view>
            <text class="header-text">与您的AI分身对话</text>
          </view>
        </view>

        <view class="search-container" @click="goToChat">
          <view class="search-box">
            <text class="placeholder-text">您想了解什么？例如：我的数据价值是多少？</text>
            <view class="search-icon">
              <text class="search-emoji">🔍</text>
            </view>
          </view>
        </view>
      </view>

      <!-- Stats Row -->
      <view class="stats-row">
        <view class="stat-item">
          <text class="stat-number">42</text>
          <text class="stat-label">积分</text>
        </view>
        <view class="stat-item">
          <text class="stat-number">3</text>
          <text class="stat-label">凭证</text>
        </view>
        <view class="stat-item">
          <text class="stat-number">5</text>
          <text class="stat-label">授权</text>
        </view>
      </view>
    </view>

    <!-- Menu Grid -->
    <view class="menu-grid">
      <view class="menu-row">
        <view class="menu-item">
          <view class="menu-icon lock">
            <text class="icon-emoji">🔒</text>
          </view>
          <text class="menu-text">隐私设置</text>
        </view>

        <view class="menu-item">
          <view class="menu-icon chart">
            <text class="icon-emoji">📊</text>
          </view>
          <text class="menu-text">数据授权</text>
        </view>
      </view>

      <view class="menu-row">
        <view class="menu-item">
          <view class="menu-icon chat">
            <text class="icon-emoji">📝</text>
          </view>
          <text class="menu-text">消费报告</text>
        </view>

        <view class="menu-item">
          <view class="menu-icon sync">
            <text class="icon-emoji">🔄</text>
          </view>
          <text class="menu-text">数据同步</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { useTheme } from '@/hooks';

export default {
  data() {
    return {};
  },
  setup() {
    const { theme } = useTheme();
    return {
      theme
    };
  },
  methods: {
    goToChat() {
      uni.navigateTo({
        url: '/pages/chat/index'
      });
    }
  }
};
</script>

<style lang="scss" scoped>
/* 全局重置 */
* {
  box-sizing: border-box;
}

.container {
  background: var(--bsin-bgPrimary);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  transition: background 0.3s ease;
  padding-bottom: calc(60px + 40px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  padding-top: 0;
}

/* 暗色模式背景 */
.container.theme-dark {
  background: var(--bsin-bgPrimary);
}

.chat-container {
  background: var(--bsin-bgCard);
  padding: 20px;
  width: 100%;
  max-width: 100%;
  border-radius: 20px;
  margin: 20px 0;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease;
}

.theme-dark .chat-container {
  background: var(--bsin-bgCard);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.chat-header {
  background: transparent;
  padding: 0;
  margin-bottom: 15px;
}

.header-content {
  display: flex;
  align-items: center;
}

.ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 12px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.ai-icon {
  font-size: 18px;
}

.avatar-image {
  width: 20px;
  height: 20px;
}

.header-text {
  font-size: 16px;
  font-weight: 600;
  color: #2d3748;
  flex: 1;
  transition: color 0.3s ease;
}

.theme-dark .header-text {
  color: #e2e8f0;
}

.search-container {
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.search-container:active {
  transform: scale(0.98);
}

.search-box {
  background: var(--bsin-bgSecondary);
  border-radius: 25px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  width: 100%;
  border: 1px solid rgba(102, 126, 234, 0.1);
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease,
    transform 0.2s ease;
}

.search-container:active .search-box {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.theme-dark .search-box {
  background: var(--bsin-bgSecondary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(74, 85, 104, 0.3);
}

.placeholder-text {
  color: #718096;
  font-size: 14px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.theme-dark .placeholder-text {
  color: #a0aec0;
}

.search-icon {
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.search-emoji {
  font-size: 16px;
}

/* Profile Header */
.profile-header {
  padding: 40px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.avatar-container {
  position: relative;
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}

.avatar-container:hover {
  transform: scale(1.05);
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4299e1, #667eea);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 25px rgba(66, 153, 225, 0.3);
  border: 4px solid rgba(255, 255, 255, 0.9);
  transition:
    border 0.3s ease,
    box-shadow 0.3s ease;
}

.theme-dark .avatar {
  border: 4px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 25px rgba(66, 153, 225, 0.4);
}

.avatar-text {
  color: white;
  font-size: 32px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-dot {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #48bb78, #38a169);
  border-radius: 50%;
  position: absolute;
  bottom: 8px;
  right: 8px;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
  transition: box-shadow 0.3s ease;
}

.theme-dark .status-dot {
  box-shadow: 0 2px 8px rgba(72, 187, 120, 0.4);
}

.profile-name {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 8px;
  text-align: center;
  color: #2d3748;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: color 0.3s ease;
}

.theme-dark .profile-name {
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.profile-did {
  font-size: 14px;
  color: #4a5568;
  margin-bottom: 20px;
  text-align: center;
  word-break: break-all;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 15px;
  backdrop-filter: blur(10px);
  transition:
    background 0.3s ease,
    color 0.3s ease;
  border: 1px solid rgba(102, 126, 234, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.theme-dark .profile-did {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Stats Row */
.stats-row {
  display: flex;
  width: 100%;
  justify-content: space-around;
  padding: 20px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.1);
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease;
}

.theme-dark .stats-row {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  background: rgba(255, 255, 255, 0.6);
  padding: 15px 10px;
  border-radius: 15px;
  margin: 0 5px;
  backdrop-filter: blur(10px);
  transition: background 0.3s ease;
  border: 1px solid rgba(102, 126, 234, 0.15);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.theme-dark .stat-item {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.stat-number {
  font-size: 24px;
  font-weight: bold;
  color: #2d3748;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: color 0.3s ease;
}

.theme-dark .stat-number {
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stat-label {
  font-size: 13px;
  color: #718096;
  margin-top: 4px;
  transition: color 0.3s ease;
}

.theme-dark .stat-label {
  color: rgba(255, 255, 255, 0.9);
}

/* Menu Grid */
.menu-grid {
  padding: 0 20px 40px;
  width: 100%;
}

.menu-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  gap: 15px;
}

.menu-item {
  background: var(--bsin-bgCard);
  border-radius: 20px;
  padding: 25px 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  min-width: 0;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.theme-dark .menu-item {
  background: var(--bsin-bgCard);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(74, 85, 104, 0.3);
}

.menu-item:active {
  transform: translateY(2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.theme-dark .menu-item:active {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.menu-icon {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e0);
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: background 0.3s ease;
}

.theme-dark .menu-icon {
  background: linear-gradient(135deg, #4a5568, #2d3748);
}

.icon-emoji {
  font-size: 22px;
}

.menu-text {
  font-size: 14px;
  color: #2d3748;
  text-align: center;
  word-break: keep-all;
  font-weight: 500;
  transition: color 0.3s ease;
}

.theme-dark .menu-text {
  color: #e2e8f0;
}

/* Chat Button */
.chat-button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 25px;
  padding: 15px 25px;
  margin-bottom: 20px;
  width: 100%;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.chat-button-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-button-text {
  color: white;
  margin-left: 8px;
  font-size: 16px;
  font-weight: 600;
}

/* Search Bar */
.search-bar {
  background: var(--bsin-bgSecondary);
  border-radius: 25px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  width: 100%;
  border: 1px solid rgba(102, 126, 234, 0.1);
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease;
}

.theme-dark .search-bar {
  background: var(--bsin-bgSecondary);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(74, 85, 104, 0.3);
}

.search-text {
  color: #718096;
  font-size: 14px;
  flex: 1;
  transition: color 0.3s ease;
}

.theme-dark .search-text {
  color: #a0aec0;
}

/* 响应式设计 */
@media (max-width: 375px) {
  .container {
    padding-bottom: calc(60px + 30px + env(safe-area-inset-bottom));
  }

  .profile-header {
    padding: 30px 15px 15px;
  }

  .menu-item {
    padding: 20px 10px;
  }

  .menu-icon {
    width: 45px;
    height: 45px;
  }

  .icon-emoji {
    font-size: 18px;
  }

  .menu-text {
    font-size: 12px;
  }

  .placeholder-text {
    font-size: 12px;
  }

  .avatar {
    width: 80px;
    height: 80px;
  }

  .avatar-text {
    font-size: 28px;
  }
}
</style>
